package tech.aistar.day07;

import java.io.Serializable;

/**
 * 本类用来演示: 图书的详情
 *
 * @author: success
 * @date: 2022/7/26 9:29 上午
 */
public class BookInfo implements Serializable {
    private int id;

    private String author;

    public BookInfo() {
    }

    public BookInfo(int id, String author) {
        this.id = id;
        this.author = author;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    //@Override
    //public boolean equals(Object obj){
    //    if(obj == null)
    //        return false;
    //    if(this == obj)
    //        return true;
    //    if(obj instanceof BookInfo){
    //        BookInfo info = (BookInfo) obj;
    //        return id == info.id;
    //    }
    //    return false;
    //}


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        BookInfo info = (BookInfo) o;

        return id == info.id;
    }

    @Override
    public int hashCode() {
        return id;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("BookInfo{");
        sb.append("id=").append(id);
        sb.append(", author='").append(author).append('\'');
        sb.append('}');
        return sb.toString();
    }
}
